<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Spec::Mocks::ArgumentExpectation</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Spec::Mocks::ArgumentExpectation</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/plugins/rspec/lib/spec/mocks/argument_expectation_rb.html">
                vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000107">check_args</a>&nbsp;&nbsp;
      <a href="#M000108">constraints_match?</a>&nbsp;&nbsp;
      <a href="#M000105">convert_constraint</a>&nbsp;&nbsp;
      <a href="#M000106">is_matcher?</a>&nbsp;&nbsp;
      <a href="#M000102">new</a>&nbsp;&nbsp;
      <a href="#M000103">process_arg_constraints</a>&nbsp;&nbsp;
      <a href="#M000104">warn_deprecated</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">args</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000102" class="method-detail">
        <a name="M000102"></a>

        <div class="method-heading">
          <a href="#M000102" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000102-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000102-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb, line 120</span>
120:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">args</span>)
121:         <span class="ruby-ivar">@args</span> = <span class="ruby-identifier">args</span>
122:         <span class="ruby-keyword kw">if</span> [<span class="ruby-identifier">:any_args</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">args</span>
123:           <span class="ruby-ivar">@expected_params</span> = <span class="ruby-keyword kw">nil</span>
124:           <span class="ruby-identifier">warn_deprecated</span>(<span class="ruby-identifier">:any_args</span>.<span class="ruby-identifier">inspect</span>, <span class="ruby-value str">&quot;any_args()&quot;</span>)
125:         <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">AnyArgsConstraint</span>) <span class="ruby-keyword kw">then</span> <span class="ruby-ivar">@expected_params</span> = <span class="ruby-keyword kw">nil</span>
126:         <span class="ruby-keyword kw">elsif</span> [<span class="ruby-identifier">:no_args</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">args</span>
127:           <span class="ruby-ivar">@expected_params</span> = []
128:           <span class="ruby-identifier">warn_deprecated</span>(<span class="ruby-identifier">:no_args</span>.<span class="ruby-identifier">inspect</span>, <span class="ruby-value str">&quot;no_args()&quot;</span>)
129:         <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">NoArgsConstraint</span>) <span class="ruby-keyword kw">then</span> <span class="ruby-ivar">@expected_params</span> = []
130:         <span class="ruby-keyword kw">else</span> <span class="ruby-ivar">@expected_params</span> = <span class="ruby-identifier">process_arg_constraints</span>(<span class="ruby-identifier">args</span>)
131:         <span class="ruby-keyword kw">end</span>
132:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000107" class="method-detail">
        <a name="M000107"></a>

        <div class="method-heading">
          <a href="#M000107" class="method-signature">
          <span class="method-name">check_args</span><span class="method-args">(args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000107-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000107-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb, line 168</span>
168:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">check_args</span>(<span class="ruby-identifier">args</span>)
169:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@expected_params</span>.<span class="ruby-identifier">nil?</span>
170:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@expected_params</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">args</span>
171:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">constraints_match?</span>(<span class="ruby-identifier">args</span>)
172:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000108" class="method-detail">
        <a name="M000108"></a>

        <div class="method-heading">
          <a href="#M000108" class="method-signature">
          <span class="method-name">constraints_match?</span><span class="method-args">(args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000108-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000108-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb, line 174</span>
174:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">constraints_match?</span>(<span class="ruby-identifier">args</span>)
175:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">!=</span> <span class="ruby-ivar">@expected_params</span>.<span class="ruby-identifier">length</span>
176:         <span class="ruby-ivar">@expected_params</span>.<span class="ruby-identifier">each_index</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@expected_params</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">matches?</span>(<span class="ruby-identifier">args</span>[<span class="ruby-identifier">i</span>]) }
177:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
178:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000105" class="method-detail">
        <a name="M000105"></a>

        <div class="method-heading">
          <a href="#M000105" class="method-signature">
          <span class="method-name">convert_constraint</span><span class="method-args">(constraint)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000105-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000105-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb, line 144</span>
144:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">convert_constraint</span>(<span class="ruby-identifier">constraint</span>)
145:         <span class="ruby-keyword kw">if</span> [<span class="ruby-identifier">:anything</span>, <span class="ruby-identifier">:numeric</span>, <span class="ruby-identifier">:boolean</span>, <span class="ruby-identifier">:string</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">constraint</span>)
146:           <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">constraint</span>
147:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:anything</span>
148:             <span class="ruby-identifier">instead</span> = <span class="ruby-value str">&quot;anything()&quot;</span>
149:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:boolean</span>
150:             <span class="ruby-identifier">instead</span> = <span class="ruby-value str">&quot;boolean()&quot;</span>
151:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:numeric</span>
152:             <span class="ruby-identifier">instead</span> = <span class="ruby-value str">&quot;an_instance_of(Numeric)&quot;</span>
153:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:string</span>
154:             <span class="ruby-identifier">instead</span> = <span class="ruby-value str">&quot;an_instance_of(String)&quot;</span>
155:           <span class="ruby-keyword kw">end</span>
156:           <span class="ruby-identifier">warn_deprecated</span>(<span class="ruby-identifier">constraint</span>.<span class="ruby-identifier">inspect</span>, <span class="ruby-identifier">instead</span>)
157:           <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@@constraint_classes</span>[<span class="ruby-identifier">constraint</span>].<span class="ruby-identifier">new</span>(<span class="ruby-identifier">constraint</span>)
158:         <span class="ruby-keyword kw">end</span>
159:         <span class="ruby-keyword kw">return</span> <span class="ruby-constant">MatcherConstraint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">constraint</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">is_matcher?</span>(<span class="ruby-identifier">constraint</span>)
160:         <span class="ruby-keyword kw">return</span> <span class="ruby-constant">RegexpArgConstraint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">constraint</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">constraint</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Regexp</span>)
161:         <span class="ruby-keyword kw">return</span> <span class="ruby-constant">LiteralArgConstraint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">constraint</span>)
162:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000106" class="method-detail">
        <a name="M000106"></a>

        <div class="method-heading">
          <a href="#M000106" class="method-signature">
          <span class="method-name">is_matcher?</span><span class="method-args">(obj)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000106-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000106-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb, line 164</span>
164:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_matcher?</span>(<span class="ruby-identifier">obj</span>)
165:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:matches?</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:description</span>)
166:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000103" class="method-detail">
        <a name="M000103"></a>

        <div class="method-heading">
          <a href="#M000103" class="method-signature">
          <span class="method-name">process_arg_constraints</span><span class="method-args">(constraints)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000103-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000103-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb, line 134</span>
134:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_arg_constraints</span>(<span class="ruby-identifier">constraints</span>)
135:         <span class="ruby-identifier">constraints</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">constraint</span><span class="ruby-operator">|</span> 
136:           <span class="ruby-identifier">convert_constraint</span>(<span class="ruby-identifier">constraint</span>)
137:         <span class="ruby-keyword kw">end</span>
138:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000104" class="method-detail">
        <a name="M000104"></a>

        <div class="method-heading">
          <a href="#M000104" class="method-signature">
          <span class="method-name">warn_deprecated</span><span class="method-args">(deprecated_method, instead)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000104-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000104-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb, line 140</span>
140:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">warn_deprecated</span>(<span class="ruby-identifier">deprecated_method</span>, <span class="ruby-identifier">instead</span>)
141:         <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;The #{deprecated_method} constraint is deprecated. Use #{instead} instead.&quot;</span>
142:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>